package com.cxhc.demo1005;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.cxhc.demo1005.View.ClockView;

public class Cframgent extends Fragment {

    RecyclerView  recyclerView;
    private Context  context;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_c,container,false);
        context = getActivity();
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
//        ClockView clockView = view.findViewById(R.id.clock);
//        clockView.start();

        recyclerView = view.findViewById(R.id.rv);
        recyclerView.setLayoutManager(new GridLayoutManager(context,6));
        recyclerView.setAdapter(new GoodAdapter());
//        recyclerView.setAdapter(getAdapter(recyclerView.get));
    }

   RecyclerView.Adapter getAdapter(int pos){
        if (pos%3==0){
            return new TextAdapter();
        }else {
            return new GoodAdapter();
        }
   }
}
